package models

type Response struct {
	Code      int         `json:"code"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data"`
	OriginUrl string      `json:"originUrl,omitempty"` // 来源URL
}

func Success(data interface{}) *Response {
	return &Response{
		Code:    0,
		Message: "OK",
		Data:    data,
	}
}

func Error(code int, message string) *Response {
	return &Response{
		Code:    code,
		Message: message,
		Data:    nil,
	}
}

func ErrorWithData(code int, message string, data interface{}) *Response {
	return &Response{
		Code:    code,
		Message: message,
		Data:    data,
	}
}

type LoginRes struct {
	AccessToken string `json:"accessToken"`
}

type UserDetailRes struct {
	User        `xorm:"extends"`
	Profile     *Profile `json:"profile" xorm:"-"`
	Roles       []*Role  `json:"roles" xorm:"-"`
	CurrentRole *Role    `json:"currentRole" xorm:"-"`
}

type RoleListRes []*Role

//	type UserListItem struct {
//		User  `xorm:"extends"`
//		Roles []*Role `json:"roles" xorm:"-"`
//	}
type UserListRes struct {
	PageData []User `json:"pageData"`
	Total    int64  `json:"total"`
}
type RoleListPageItem struct {
	Role          `xorm:"extends"`
	PermissionIds []int64 `json:"permissionIds" xorm:"-"`
}
type RoleListPageRes struct {
	PageData []RoleListPageItem `json:"pageData"`
	Total    int64              `json:"total"`
}
